package com.nus;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

import com.nus.parsers.ParserAPIs;
import com.nus.representations.IvleStudentEvents;
import com.nus.IvleStudentEventActivity;
public class IvleStudent_EventDetails_Activity extends Activity {
	//private ListView lv;
	private String lv_Details_arr[];
	public ImageButton home;
	protected TextView title;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.ivlestudenteventsdetails);
		 getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
		 title = (TextView) findViewById(R.id.titleheader);
		 title.setText("Student Events");
		 ImageView b = (ImageView)findViewById(R.id.home);
		  b.setImageDrawable(getResources().getDrawable(R.drawable.events));
//		 home = (ImageButton) findViewById(R.id.home);
//	        home.setOnClickListener(new OnClickListener() {
//				
////				@Override
//				public void onClick(View v) {
//					// TODO Auto-generated method stub
//					startActivity(new Intent("com.nus.OptionsActivity"));
//				}
//			});
	        boolean netconn = checkInternetConnection();
			if(!netconn){
				Toast.makeText(getApplicationContext(), "Please check your internet or 3G connection", Toast.LENGTH_LONG).show();       
	        }
		final TextView textView = (TextView) findViewById(R.id.Agenda_Value);
		if(!IvleStudentEventActivity.Student_Event_Agenda.equals(""))
			textView.setText(IvleStudentEventActivity.Student_Event_Agenda);
		else
			textView.setText("-");
		
		final TextView textView1 = (TextView) findViewById(R.id.Title_Value);
		textView1.setText(IvleStudentEventActivity.Student_Event_Title);
		
		final TextView textView2 = (TextView) findViewById(R.id.Description_Value);
		textView2.setText(Html.fromHtml(IvleStudentEventActivity.Student_Event_Description));
		textView2.setMovementMethod(LinkMovementMethod.getInstance());
		textView2.setMovementMethod(ScrollingMovementMethod.getInstance());

		
		final TextView textView3 = (TextView) findViewById(R.id.Contact_Value);
		if(!IvleStudentEventActivity.Student_Event_Contact.equals("")){
			textView3.setText(IvleStudentEventActivity.Student_Event_Contact);
			textView3.setMovementMethod(LinkMovementMethod.getInstance());
			textView3.setMovementMethod(ScrollingMovementMethod.getInstance());
		}
		else {
			textView3.setText("-");
		}
		
		final TextView textView4 = (TextView) findViewById(R.id.DateTime_Value);
		if(!IvleStudentEventActivity.Student_Event_DateTime.equals("")){
			textView4.setText(IvleStudentEventActivity.Student_Event_DateTime);
			textView4.setMovementMethod(LinkMovementMethod.getInstance());
			textView4.setMovementMethod(ScrollingMovementMethod.getInstance());
		}
		else
			textView4.setText("-");
		
		final TextView textView5 = (TextView) findViewById(R.id.Venue_Value);
		if(!IvleStudentEventActivity.Student_Event_Venue.equals("")){
			textView5.setText(IvleStudentEventActivity.Student_Event_Venue);
			textView5.setMovementMethod(LinkMovementMethod.getInstance());
			textView5.setMovementMethod(ScrollingMovementMethod.getInstance());
		}
		else
			textView5.setText("-");
		
		final TextView textView6 = (TextView) findViewById(R.id.Price_Value);
		if(!IvleStudentEventActivity.Student_Event_Price.equals("")){
			textView6.setText(IvleStudentEventActivity.Student_Event_Price);
			textView6.setMovementMethod(LinkMovementMethod.getInstance());
			textView6.setMovementMethod(ScrollingMovementMethod.getInstance());
		}
		else
			textView6.setText("-");
		
		final TextView textView7 = (TextView) findViewById(R.id.Organizer_Value);
		if(!IvleStudentEventActivity.Student_Event_Organizer.equals("")){
			textView7.setText(IvleStudentEventActivity.Student_Event_Organizer);
			textView7.setMovementMethod(LinkMovementMethod.getInstance());
			textView7.setMovementMethod(ScrollingMovementMethod.getInstance());
		}
		else
			textView7.setText("-");
	}
//	 @Override
//		public void onBackPressed() { 	
//	    	//OptionsActivity.i = 1;
//	    	//Activity below = this.getParent();
//	    	this.finish();
//	    	//below.finish();
//	    	startActivity(new Intent("com.nus.IvleStudentEventActivity").putExtra("IVLE_Token", NUS_Android.IVLE_Token));
//		    return;
//		}
	 public boolean checkInternetConnection() {
	        ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

	        if (cm.getActiveNetworkInfo() != null && cm.getActiveNetworkInfo().isAvailable() && cm.getActiveNetworkInfo().isConnected()) {
	            return true;

	        } else {
	            return false;
	        }
	    }
}
